﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Entidad;
using System.Data;

namespace GestionDatos
{
    public class Programa
    {

        SqlConnection conexion;

        public Programa()
        {
            conexion = new SqlConnection(ConexionBD.CadenaConexion);
        }

        public void InsertarPrograma(Entidad.Programa ent)
       
        {       /*string prog;*/
                SqlCommand cmdPrograma = new SqlCommand("dbo.usp_agregar_programa", conexion);
                cmdPrograma.CommandType = CommandType.StoredProcedure;
           
                conexion.Open();
                /*prog = (string)cmdPrograma.ExecuteScalar();*/
              

                cmdPrograma.Parameters.AddWithValue("@tipoPrograma", ent.TipoPrograma);
                cmdPrograma.Parameters.AddWithValue("@nombre", ent.Nombre);
                cmdPrograma.Parameters.AddWithValue("@presentacion", ent.Presentacion);
                cmdPrograma.Parameters.AddWithValue("@mision", ent.Mision);
                cmdPrograma.Parameters.AddWithValue("@vision", ent.Vision);
                cmdPrograma.Parameters.AddWithValue("@objetivos", ent.Objetivos);
                cmdPrograma.Parameters.AddWithValue("@perfilEstudiante",ent.PerfilEstudiante);
                cmdPrograma.Parameters.AddWithValue("@perfilEgresado", ent.PerfilEgresado);
                cmdPrograma.Parameters.AddWithValue("@horario", ent.Horario);
                cmdPrograma.Parameters.AddWithValue("@inscripcion", ent.Inscripcion);
                cmdPrograma.Parameters.AddWithValue("@matricula", ent.Matricula);
                cmdPrograma.Parameters.AddWithValue("@pension",ent.Pension);
                cmdPrograma.Parameters.AddWithValue("@metadatos", ent.Metadatos);
                cmdPrograma.Parameters.AddWithValue("@url", ent.Url);
                cmdPrograma.Parameters.AddWithValue("@idplanEstudio", ent.IdPlanEstudio);
                cmdPrograma.Parameters.AddWithValue("@idDocente", ent.IdDocente);


              /*  cmdPrograma.Parameters.AddWithValue("@tipoPrograma", null);
                cmdPrograma.Parameters.AddWithValue("@nombre", null);
                cmdPrograma.Parameters.AddWithValue("@presentacion", ent.Presentacion);
                cmdPrograma.Parameters.AddWithValue("@mision", null);
                cmdPrograma.Parameters.AddWithValue("@vision", null);
                cmdPrograma.Parameters.AddWithValue("@objetivos", null);
                cmdPrograma.Parameters.AddWithValue("@perfilEstudiante", null);
                cmdPrograma.Parameters.AddWithValue("@perfilEgresado", null);
                cmdPrograma.Parameters.AddWithValue("@horario", null);
                cmdPrograma.Parameters.AddWithValue("@inscripcion", null);
                cmdPrograma.Parameters.AddWithValue("@matricula", null);
                cmdPrograma.Parameters.AddWithValue("@pension", null);
                cmdPrograma.Parameters.AddWithValue("@idplanEstudio", null);
                cmdPrograma.Parameters.AddWithValue("@idDocente", null);*/

                cmdPrograma.ExecuteNonQuery();
                conexion.Close();
        
                return ;
    
            }
      public DataSet SelectProgramas()
        {
          DataSet dsprogra= new DataSet();
          SqlCommand cmdprograma = new SqlCommand("dbo.usp_listar_programas", conexion);
          SqlDataAdapter da = new SqlDataAdapter("dbo.usp_listar_programas", conexion);
          da.SelectCommand = cmdprograma;
          conexion.Open();
          cmdprograma.ExecuteNonQuery();
          da.Fill(dsprogra, "PROGRAMAS");
          
          conexion.Close();
         // conexion.Dispose();
        

          return dsprogra;
        }

        /*      DataSet dsavisos = new DataSet();
            //string select = "SELECT * FROM avisos WHERE visible=1";
            string select = "SELECT * FROM avisos WHERE etiquetas LIKE '%" + av.Etiquetas + "%' AND visible='1'";
            SqlDataAdapter daAvisos = new SqlDataAdapter(select, conexion);
            daAvisos.Fill(dsavisos, "AVISOS");
            return dsavisos; */
}
}